Skip to content

Add Dynamic Workers runtime for cloud code execution - #124

Merged
RhysSullivan merged 4 commits into
mainfrom
feat/dynamic-worker-runtime
Apr 9, 2026
Merged

Add Dynamic Workers runtime for cloud code execution#124
RhysSullivan merged 4 commits into
mainfrom
feat/dynamic-worker-runtime

Conversation

@RhysSullivan

Copy link
Copy Markdown
Collaborator

Summary

  • Adds @executor/runtime-dynamic-worker package (packages/kernel/runtime-dynamic-worker/) — a new CodeExecutor implementation that runs sandboxed code in isolated Cloudflare Workers via the WorkerLoader binding
  • Tool calls dispatch over Workers RPC through a ToolDispatcher that bridges back to the existing SandboxToolInvoker interface
  • Cloud app wired to use dynamic workers for code execution instead of QuickJS, with the worker_loaders binding configured in wrangler.jsonc
  • Centralizes all Cloudflare bindings (HYPERDRIVE, LOADER, MARKETING) in a single cf export in env.ts — replaces scattered dynamic import("cloudflare:workers") calls and as any casts with static typed access
  • Adds @cloudflare/workers-types to the cloud app for proper type safety

Test plan

  • 17 unit tests passing for normalize + module template generation
  • Cloud app typechecks clean
  • Deploy to Cloudflare Workers and verify code execution works end-to-end
  • Verify tool invocation dispatches correctly over RPC
  • Verify globalOutbound: null blocks direct network access from sandboxed code

Introduces @executor/runtime-dynamic-worker, a new CodeExecutor implementation
that runs sandboxed code in isolated Cloudflare Workers via the WorkerLoader
binding. Tool calls dispatch over Workers RPC through a ToolDispatcher that
bridges back to the existing SandboxToolInvoker interface.

Cloud app changes:
- Wire dynamic worker executor into the execution engine
- Centralize all Cloudflare bindings in env.ts (single boundary)
- Replace dynamic imports and `as any` casts with static typed access
- Add @cloudflare/workers-types and include worker-configuration.d.ts in tsconfig
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Apr 9, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
executor-marketing fa15e05 Commit Preview URL

Branch Preview URL
Apr 09 2026, 02:22 AM

Vitest 4 changes the default test include pattern and exits with code 1
when no test files match. Add local vitest.config.ts to packages that
were relying on the old default, with passWithNoTests for packages that
have no tests yet.

This unblocks @cloudflare/vitest-pool-workers for integration testing
dynamic workers in the Workers runtime.
Tests run in the actual Workers runtime via @cloudflare/vitest-pool-workers.
Covers ToolDispatcher RPC dispatch, full code execution via WorkerLoader,
console capture, tool invocation through the proxy, timeout enforcement,
and egress blocking with globalOutbound: null.
makeTestConfig sets scope.name to the cwd which defaults to "/test",
not "test". Update the assertion to match.
@RhysSullivan
RhysSullivan merged commit 473731b into main Apr 9, 2026
2 checks passed
RhysSullivan added a commit that referenced this pull request May 31, 2026
* Add Dynamic Workers runtime for cloud code execution

Introduces @executor/runtime-dynamic-worker, a new CodeExecutor implementation
that runs sandboxed code in isolated Cloudflare Workers via the WorkerLoader
binding. Tool calls dispatch over Workers RPC through a ToolDispatcher that
bridges back to the existing SandboxToolInvoker interface.

Cloud app changes:
- Wire dynamic worker executor into the execution engine
- Centralize all Cloudflare bindings in env.ts (single boundary)
- Replace dynamic imports and `as any` casts with static typed access
- Add @cloudflare/workers-types and include worker-configuration.d.ts in tsconfig

* Upgrade vitest to 4.1+ and @effect/vitest to 0.29

Vitest 4 changes the default test include pattern and exits with code 1
when no test files match. Add local vitest.config.ts to packages that
were relying on the old default, with passWithNoTests for packages that
have no tests yet.

This unblocks @cloudflare/vitest-pool-workers for integration testing
dynamic workers in the Workers runtime.

* Add integration tests for dynamic worker execution

Tests run in the actual Workers runtime via @cloudflare/vitest-pool-workers.
Covers ToolDispatcher RPC dispatch, full code execution via WorkerLoader,
console capture, tool invocation through the proxy, timeout enforcement,
and egress blocking with globalOutbound: null.

* Fix SDK test expecting wrong scope name

makeTestConfig sets scope.name to the cwd which defaults to "/test",
not "test". Update the assertion to match.
@RhysSullivan
RhysSullivan deleted the feat/dynamic-worker-runtime branch June 11, 2026 08:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant